﻿<!DOCTYPE html>
<html>
<head>
    <title>修改</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>
<form class="layui-form"  action="" lay-filter="edit">
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">id：</label>-->
<!--        <div class="layui-input-inline layui-col-md4">-->
<!--            <input type="text" name="id" id="id"  required  lay-verify="required" placeholder="请输入id" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
<input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">标题：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="title" id="title"  required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="contents" id="contents"  required  lay-verify="required" placeholder="请输入内容" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>
<script src="/static/js/system.js"></script>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
        //Demo
        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            $.ajax({
                url: '/announ/findId',
                type: "post",
                dataType: "json",
                data: {"id": getQueryString("id")},
                success: function (da) {
                    console.log(da)
                    if (da.code == 200) {
                        form.val("edit", da.date);
                    } else {
                        parent.layer.msg("详情查询失败！");
                    }
                }
            });

            //监听提交
            form.on('submit(formDemo)', function (data) {
                var data1 = form.val("edit");
                $.ajax({
                    url: '/announ/update',
                    type: "post",
                    dataType: "json",
                    data: data1,
                    success: function (da) {
                        console.log(da)
                        if (da.code == 200) {
                            layer.alert("修改成功！", function () {
                                // window.parent.location.reload();//刷新父页面
                                // parent.layer.close(layer.index);//关闭弹出层
                                parent.layer.closeAll();
                            });
                        } else {
                            layer.msg("修改失败！");
                        }
                    }
                });
                return false;
            });

        });

</script>
</html>